<?php
require_once(PATH_TO_APP . "/components/tabledatagateway/TableDataGateway.php");

class ExcelExportGateway extends TableDataGateway
{           

    private $where_condition_ = '';
        
    public function __construct()
    {
        $this->establishConnection();
    }
        
    public function __destruct(){}
    
    public function getExcelData($table, $shape_id)
    {
        $statement = "SELECT region_id, region, dt.* FROM ".$table." as dt, shape_".$shape_id." as s where dt.gid=s.gid";
        if(strlen($this->where_condition_) > 0)
            $statement .= "where ".$this->where_condition_;
        $statement .= " order by region_id";
        $stmt = $this->database_connection_->newStatement($statement);
        $stmt->execute();
        $arr_return = array();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC))
            $arr_return[] = $row;
        return $arr_return;
    }
}    
?>
